<?php
# $Id:
require_once(APP_LIB_DIR . 'BaseModel.class.php');
Class UserTypeModel Extends BaseModel
{

	function add_usertype($detail)
    {
    	$this->insert('usertype', $detail);
        return $this->get_last_insert_id('usertype');
    }

    function update_usertype($id, $detail)
    {
        return $this->update('usertype', $detail, "id = '$id'");
    }

	function delete_usertype($id)
	{
    	$query = "UPDATE usertype SET active='N' WHERE id=$id";
        return $this->query($query, false);
	}

	function get_details($id)
	{
    	$query = "SELECT *  FROM usertype WHERE active='Y' AND  id='$id'";
        return $this->query($query, true);
	}

	function count_usertype()
	{
		$query = "SELECT COUNT(*) FROM usertype WHERE active='Y'";
		$num = $this->query($query, true);
        return $num[0][0];
	}

	function get_list($offset, $limit)
	{
		$query = "SELECT * FROM usertype WHERE active='Y' LIMIT $offset, $limit";
        return $this->query($query, true);
	}
	
	function check_list($name)
	{
    	$query = "SELECT *  FROM usertype WHERE usertype_name='$name'";
        return $this->query($query, true);
	}
}
?>
